#pip install matplotlib
import networkx as nx
import matplotlib.pyplot as plt
import random
from typing import List
from dataclasses import dataclass
options = {
"font_size": 10,
"node_size": 300,
"node_color": "white",
"edgecolors": "black",
"linewidths": 1,
"width": 1,
}
n = 100
p = 0.1
x = []
y = []
Gs = []
def generatGraph(p, ax):
G = nx.fast_gnp_random_graph(100,p)
Gs.append(G)
nx.draw_networkx(G, **options, ax = ax)
largest = len(sorted(nx.connected_components(G), key=len, reverse=True)[0])
ax.set_title("Probability : " + str(p) + "\nSize of the largest connected component " + str(largest))
x.append(p)
y.append(largest)
fig, axs = plt.subplots(20,5,figsize=(40,250))
for i in range(100):
generatGraph(i/100, axs[i//5, i%5])